/*
 * TCSS 360 - Winter 2014
 * TESK Software
 */
package view.userProfile;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import view.CurrentConference;
import view.LogInView;
import view.MainFrame;
import view.SelectConferenceAuthor;
import view.Papers.SubmitPaperView;
import view.personalInfo.ContactView;
import javax.swing.border.SoftBevelBorder;
import javax.swing.border.BevelBorder;
import java.awt.Font;
import javax.swing.border.MatteBorder;


/**
 * Profile view for author.
 * @author Kon
 * @version 3/3/14.
 */
@SuppressWarnings("serial")
public class AuthorView extends JPanel{
	private MainFrame my_frame;
	private AuthorView my_view;

	
	/**
	 * Constructs the author view.
	 * 
	 * @param the_frame the frame the panel is to associate with
	 */
	public AuthorView(final MainFrame the_frame){
		super();
		my_frame = the_frame;
		my_view = this;
		
		init();
		this.setBackground(new Color(245, 222, 179));

	}
	
	/**
	 * Adds the specifications and components of the panel.
	 */
	public void init(){
		setLayout(new GridLayout(0, 2, 0, 0));
		final JPanel headerPanel = new JPanel();	
		headerPanel.setBackground(new Color(46, 139, 87));
		add(headerPanel);
		headerPanel.setOpaque(false);
		headerPanel.setLayout(null);
		
		ImageIcon icon = new ImageIcon(getClass().getResource("/annie.jpg"));
		final JLabel pic = new JLabel();
		pic.setBounds(0, 0, 250, 480);
		//pic.setIcon(new ImageIcon("..\\Conference System\\src\\annie.jpg"));
		pic.setIcon(icon);
		headerPanel.add(pic);
		
		JPanel panel = new JPanel();
		panel.setBorder(new MatteBorder(2, 1, 6, 2, (Color) new Color(0, 0, 205)));
		panel.setBackground(new Color(224, 255, 255));
		add(panel);
		panel.setLayout(null);
		
		JPanel buttonPanel = new JPanel();
		buttonPanel.setBounds(10, 82, 205, 148);
		panel.add(buttonPanel);
		buttonPanel.setOpaque(false);
		JPanel panel_1 = new JPanel(new GridLayout(5,0)); 
		panel_1.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, new Color(186, 85, 211), new Color(127, 255, 212), new Color(199, 21, 133), new Color(221, 160, 221)));
		panel_1.setOpaque(false);
		
		final JButton currentConf = new JButton("Available Conference");
		currentConf.setFont(new Font("Tahoma", Font.BOLD, 14));
		currentConf.setForeground(new Color(148, 0, 211));
		currentConf.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {

				CurrentConference conf = new CurrentConference(my_frame);
				conf.setup();
				JPanel centerPanel = new JPanel();
				centerPanel.setLayout(new BorderLayout());
				JButton button = new JButton("Back");
				centerPanel.add(conf, BorderLayout.CENTER);
				JPanel southPanel = new JPanel();
				southPanel.add(button);
				centerPanel.add(southPanel, BorderLayout.SOUTH);
				my_frame.setNewPanel(centerPanel);
	
				button.addActionListener(new ActionListener() {
	
					@Override
					public void actionPerformed(ActionEvent arg0) {						
						my_frame.setNewPanel(my_view);
						my_frame.revalidate();
						my_frame.repaint();
					}
				});

			}
		});
		
		final JButton profile = new JButton("Profile");
		profile.setFont(new Font("Tahoma", Font.BOLD, 14));
		profile.setForeground(new Color(148, 0, 211));
		profile.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				JPanel contact = new ContactView(my_frame); 
				contact.setOpaque(false);
				my_frame.setNewPanel(contact);
				my_frame.setResizable(true);
			}
		});
		final JButton submitPaper = new  JButton("Submit A Paper");
		submitPaper.setFont(new Font("Tahoma", Font.BOLD, 14));
		submitPaper.setForeground(new Color(148, 0, 211));
		submitPaper.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JPanel paper = new SubmitPaperView(my_frame, my_view);
				paper.setOpaque(false);
				my_frame.setNewPanel(paper);
				my_frame.pack();
			}
		});
		final JButton alreadySubmitted = new JButton("View Submitted Papers");
		alreadySubmitted.setFont(new Font("Tahoma", Font.BOLD, 14));
		alreadySubmitted.setForeground(new Color(148, 0, 211));
		alreadySubmitted.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				my_frame.setNewPanel(new SelectConferenceAuthor(my_frame, my_view));
			}
		});

		final JButton logOut = new  JButton("Log Out");
		logOut.setFont(new Font("Tahoma", Font.BOLD, 14));
		logOut.setForeground(new Color(148, 0, 211));
		logOut.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {

				JPanel view = new LogInView(my_frame);
				view.setOpaque(false);
				my_frame.setNewPanel(view);
			}
		});
		panel_1.add(profile);
		panel_1.add(currentConf);
		panel_1.add(submitPaper);
		panel_1.add(alreadySubmitted);
		panel_1.add(logOut);
		buttonPanel.add(panel_1);
		
		final JLabel welcome = new JLabel("Welcome, Author! ");
		welcome.setForeground(new Color(148, 0, 211));
		welcome.setBounds(25, 24, 175, 40);
		panel.add(welcome);
		welcome.setFont(new Font("Urdu Typesetting", Font.PLAIN, 18));
	}
	
}
